﻿using DingVision.Infrastructure.Events;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DingVision.Axis.ViewModels.Dialogs
{
    public class MovePointDialogViewModel : BindableBase, IDialogAware
    {
        private readonly IEventAggregator eventAggregator;
        public string Title { get; set; } = "执行运动";
        private string movePointMessage;
        public string MovePointMessage
        {
            get { return movePointMessage; }
            set { SetProperty(ref movePointMessage, value); }
        }
        private DelegateCommand moveStopCommand;
        

        public DelegateCommand MoveStopCommand =>
            moveStopCommand ?? (moveStopCommand = new DelegateCommand(ExecuteMoveStopCommand));

        void ExecuteMoveStopCommand()
        {
            RequestClose?.Invoke(new DialogResult(ButtonResult.No));
        }
        public MovePointDialogViewModel(IEventAggregator _eventAggregator)
        {
            eventAggregator = _eventAggregator;
            eventAggregator.GetEvent<JogMovePointFinishEvent>().Subscribe(JogMovePointFinishEventReceived);
        }

        private void JogMovePointFinishEventReceived()
        {
            RequestClose?.Invoke(new DialogResult(ButtonResult.OK)); ;
        }

        public event Action<IDialogResult> RequestClose;

        public bool CanCloseDialog()
        {
            return true;
        }

        public void OnDialogClosed()
        {
            
        }

        public void OnDialogOpened(IDialogParameters parameters)
        {
            MovePointMessage = parameters.GetValue<string>("CommandMsg");
        }
    }
}
